// 反集合并
// 翻倍构造 每个点的敌人

#include<bits/stdc++.h>
using namespace std;
const int N = 1005;

int n,m;
int fath[2*N];
    
int find(int x){
    if(x==fath[x]) return x;
    return fath[x] = find(fath[x]);
}
int main(){
    cin>>n;
    cin>>m;
    for(int i=1;i<=2*n;i++) fath[i] = i;
    for(int i=1;i<=m;i++){
        int x,y;
        char ty;
        cin>>ty>>x>>y;
        if(ty=='F'){
            fath[find(x)] = find(y);
        }
        else if(ty=='E'){
            fath[find(x+n)] = find(y);
            fath[find(y+n)] = find(x);
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(fath[i]==i) ans++;
    }
    printf("%d\n",ans);
    return 0;
}